package CtrlLayer;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class Tester.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class Tester
{
    private CtrlLayer.VareCtrl vareCtrl1;
    private CtrlLayer.OrdreCtrl ordreCtr1;
    private CtrlLayer.KundeCtrl kundeCtr1;

    /**
     * Default constructor for test class Tester
     */
    public Tester()
    {
        vareCtrl1 = new CtrlLayer.VareCtrl();
        ordreCtr1 = new CtrlLayer.OrdreCtrl();
        kundeCtr1 = new CtrlLayer.KundeCtrl();
        vareCtrl1.addVare("ting", "hjælp", 20, 0);
        kundeCtr1.addKunde("knud", "der", "10101010", 10);
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void findVare()
    {
        assertNotNull(vareCtrl1.findVare("ting", 0));
    }

    @Test
    public void addVare()
    {
        vareCtrl1.addVare("pind", "pinden er farlig", 50, 0);
        assertNotNull(vareCtrl1.findVare("pind", 0));
    }

    @Test
    public void removeVare()
    {
        assertNotNull(vareCtrl1.findVare("ting", 0));
        assertEquals(true, vareCtrl1.removeVare("ting"));
        vareCtrl1.addVare("ting", "pinden er farlig", 50, 0);
    }

    @Test
    public void setVare()
    {
        vareCtrl1.setVare("ting", "tingen", null, 40, 20);
        assertNotNull(vareCtrl1.findVare("tingen", 0));
        vareCtrl1.setVare("tingen", "ting", null, 20, 0);
    }

    @Test
    public void addKunde()
    {
        kundeCtr1.addKunde("sven", "her", "20202020", 10);
        assertNotNull(kundeCtr1.findKunde("20202020"));
    }

    @Test
    public void findKunde()
    {
        assertNotNull(kundeCtr1.findKunde("10101010"));
    }

    @Test
    public void setKunde()
    {
        assertEquals(true, kundeCtr1.setKunde("10101010", "knud", null, null, 0));
        assertEquals("knud", kundeCtr1.findKunde("10101010").getNavn());
        assertEquals(true, kundeCtr1.setKunde("10101010", "sven", null, null, 0));
    }

    @Test
    public void removeKunde()
    {
        assertEquals(true, kundeCtr1.removeKunde("10101010"));
        kundeCtr1.addKunde("sven", "toflgade", "10101010", 0);
    }

    @Test
    public void opretOrdre()
    {
        ordreCtr1.opretOrdre();
        assertNotNull(ordreCtr1.findKunde("10101010"));
        assertNotNull(ordreCtr1.findVare("ting", 4));
        ordreCtr1.addDelordre();
        ordreCtr1.registrerOrdre();
        assertNotNull(ordreCtr1.findOrdre(1));
    }

    @Test
    public void flereOrdre()
    {
        ordreCtr1.opretOrdre();
        assertNotNull(ordreCtr1.findKunde("10101010"));
        assertNotNull(ordreCtr1.findVare("ting", 10));
        ordreCtr1.addDelordre();
        ordreCtr1.registrerOrdre();
        ordreCtr1.opretOrdre();
        assertNotNull(ordreCtr1.findKunde("10101010"));
        assertNotNull(ordreCtr1.findVare("ting", 1));
        ordreCtr1.addDelordre();
        ordreCtr1.registrerOrdre();
        ordreCtr1.opretOrdre();
        assertNotNull(ordreCtr1.findKunde("10101010"));
        assertNotNull(ordreCtr1.findVare("ting", 100));
        ordreCtr1.addDelordre();
        ordreCtr1.registrerOrdre();
        assertNotNull(ordreCtr1.findOrdre(1));
        assertNotNull(ordreCtr1.findOrdre(2));
        assertNotNull(ordreCtr1.findOrdre(3));
    }
}







